home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- '''Exposes a dictionary, pronunciation_dict, that maps words to what
- they sound like.'''
- __id__ = '$Id: pronunciation_dict.py 3882 2008-05-07 18:22:10Z richb $'
- __version__ = '$Revision: 3882 $'
- __date__ = '$Date: 2008-05-07 14:22:10 -0400 (Wed, 07 May 2008) $'
- __copyright__ = 'Copyright (c) 2006-2008 Sun Microsystems Inc.'
- __license__ = 'LGPL'
-
- def getPronunciation(word, pronunciations = None):
- '''Given a word, return a string that represents what this word
- sounds like.
-
- Arguments:
- - word: the word to get the "sounds like" representation for.
- - pronunciations: an optional dictionary used to get the pronunciation
- from.
-
- Returns a string that represents what this word sounds like, or
- the word if there is no representation.
- '''
- if isinstance(word, unicode):
- word = word.encode('UTF-8')
-
-
- try:
- lowerWord = word.decode('UTF-8').lower().encode('UTF-8')
- if pronunciations != None:
- return pronunciations[lowerWord][1]
- return pronunciation_dict[lowerWord][1]
- except:
- return word
-
-
-
- def setPronunciation(word, replacementString, pronunciations = None):
- '''Given an actual word, and a replacement string, set a key/value
- pair in a pronunciation dictionary.
-
- Arguments:
- - word: the word to be pronunced.
- - replacementString: the replacement string to use instead.
- - pronunciations: an optional dictionary used to set the pronunciation
- into.
- '''
- key = word.decode('UTF-8').lower().encode('UTF-8')
- if pronunciations != None:
- pronunciations[key] = [
- word,
- replacementString]
- else:
- pronunciation_dict[key] = [
- word,
- replacementString]
-
- pronunciation_dict = { }
-